//
//  YXFeedbackView.m
//  CreditCard
//
//  Created by 杨旭 on 2017/12/27.
//  Copyright © 2017年 杨旭. All rights reserved.
//

#import "YXFeedbackView.h"

@interface YXFeedbackView ()<UITextViewDelegate>

@property (weak, nonatomic) IBOutlet UITextView *contentView;


@property (strong, nonatomic) IBOutlet UIButton *submitBtn;

@end

@implementation YXFeedbackView

-(instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {
        // 从xib中找到我们定义的view
        NSArray *viewArray = [[NSBundle mainBundle]loadNibNamed:@"YXFeedbackView" owner:self options:nil];
        self = viewArray[0];
        self.frame = frame;
        
        self.contentView.delegate = self;
        self.submitBtn.layer.masksToBounds = YES;
        self.submitBtn.layer.cornerRadius = 8.0f;
        
    }
    return self;
    
}

#pragma mark - textView Delegate
-(BOOL)textViewShouldBeginEditing:(UITextView *)textView {
    
    self.textStr.text = nil;
    return YES;
}

-(BOOL)textViewShouldEndEditing:(UITextView *)textView{
    
    if (textView.text.length == 0) {
        self.textStr.text = @"请输入反馈内容";
    }
    [textView resignFirstResponder];
    [textView endEditing:YES];
    return YES;
}


- (IBAction)submitBtnAction:(UIButton *)sender {
    
    if (self.contentView.text.length == 0) {
        return;
    }else {
        self.submitBtnClickBlock(self.contentView.text);
    }
    
}



@end
